package com.sinopec.android.util;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class SharePreferencesUtil {
	//保存登录用户memberiId
	public static void saveLoginUserMemberId(Context context,String memberId){
		SharedPreferences preference = context.getSharedPreferences("loginUser",Context.MODE_PRIVATE);
        Editor edit = preference.edit();
        edit.putString("memberId",memberId);
        edit.commit();
	}
	//获取登录用户memberiId
	public static String getLoginUserMemberId(Context context){
		SharedPreferences preference = context.getSharedPreferences("loginUser",Context.MODE_PRIVATE);
		return preference.getString("memberId","");
	}
	//清空登录用户memberiId
	public static void clearLoginUserMemberId(Context context){
		SharedPreferences preference = context.getSharedPreferences("loginUser",Context.MODE_PRIVATE);
        Editor edit = preference.edit();
        edit.putString("memberId","");
        edit.commit();
	}
	
	
	//保存登录用户名
	public static void saveLoginUserName(Context context,String username){
		SharedPreferences preference = context.getSharedPreferences("loginUser",Context.MODE_PRIVATE);
        Editor edit = preference.edit();
        edit.putString("username",username);
        edit.commit();
	}
	//获取登录用户名
	public static String getLoginUserName(Context context){
		SharedPreferences preference = context.getSharedPreferences("loginUser",Context.MODE_PRIVATE);
		return preference.getString("username","");
	}
	//清空登录用户名
	public static void clearLoginUserName(Context context){
		SharedPreferences preference = context.getSharedPreferences("loginUser",Context.MODE_PRIVATE);
        Editor edit = preference.edit();
        edit.putString("username","");
        edit.commit();
	}
	
	//保存程序不是第一次启动
	public static void saveAppIsNotFirst(Context context,boolean IsNotFirst){
		SharedPreferences preference = context.getSharedPreferences("firstTime",Context.MODE_PRIVATE);
        Editor edit = preference.edit();
        edit.putBoolean("isNotFirst",IsNotFirst);
        edit.commit();
	}
	//获取程序是不是第一次启动，
	public static boolean getAppIsNotFirst(Context context){
		SharedPreferences preference = context.getSharedPreferences("firstTime",Context.MODE_PRIVATE);
		return  preference.getBoolean("isNotFirst", false);
	}
	//清楚程序不是第一次启动
	public static void clearAppIsNotFirst(Context context){
		SharedPreferences preference = context.getSharedPreferences("firstTime",Context.MODE_PRIVATE);
		Editor edit = preference.edit();
        edit.putBoolean("isNotFirst",true);
        edit.commit();
	}
	//保存上一次登录用户的账号
	public static void saveLastLoginAccount(Context context,String name,String value){
		SharedPreferences preference = context.getSharedPreferences("loginAccount",Context.MODE_PRIVATE);
        Editor edit = preference.edit();
        edit.putString(name,value);
        edit.commit();
	}
	//获得上一次登录用户的账号
	public static String getLastLoginAccount(Context context,String name){
		SharedPreferences preference = context.getSharedPreferences("loginAccount",Context.MODE_PRIVATE);
		return preference.getString(name,"");
	}
	//清除上一次登录用户的账号
	public static void clearLastLoginAccount(Context context,String name){
		SharedPreferences preference = context.getSharedPreferences("loginAccount",Context.MODE_PRIVATE);
		preference.edit().putString(name,"").commit();
	}
	
	//保存上一次设置的ip
	public static void saveIP(Context context,String name,String value){
		SharedPreferences preference = context.getSharedPreferences("setip",Context.MODE_PRIVATE);
        Editor edit = preference.edit();
        edit.putString(name,value);
        edit.commit();
	}
	//获得上一次登录用户的账号
	public static String getIP(Context context,String name){
		SharedPreferences preference = context.getSharedPreferences("setip",Context.MODE_PRIVATE);
		return preference.getString(name,"");
	}
	//清除上一次登录用户的账号
	public static void clearIP(Context context,String name){
		SharedPreferences preference = context.getSharedPreferences("setip",Context.MODE_PRIVATE);
		preference.edit().putString(name,"").commit();
	}
	
}
